package com.algorithm;

import java.util.Scanner;

public class blackHole {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int[] arr=new int[3];
        int max,min,temp=0,count=1;
        while (n!=495){
            arr[2]=n%10;
            arr[1]=n/10%10;
            arr[0]=n/10/10%10;
            for (int i=0;i<arr.length-1;i++){
                for (int j=0;j<arr.length-1-i;j++){
                    if (arr[j]>arr[j+1]){
                        temp=arr[j];
                        arr[j]=arr[j+1];
                        arr[j+1]=temp;
                    }
                }
            }
            min=arr[0]*100+arr[1]*10+arr[2];
            max=arr[2]*100+arr[1]*10+arr[0];
            n=max-min;
            System.out.println((count++)+" : "+max+" - "+min+" = "+n);
        }
    }
}
